Skip to content

[0-size Tensor No.248] Add 0-size Tensor support for reshape - #73165

Merged
wanghuancoder merged 1 commit into
PaddlePaddle:developfrom
co63oc:d1
Jun 10, 2025
Merged

wanghuancoder merged 1 commit into
PaddlePaddle:developfrom
co63oc:d1

Conversation

@co63oc

@co63oc co63oc commented Jun 8, 2025 •

Copy link
Copy Markdown
Contributor

PR Category

Execute Infrastructure

PR Types

Improvements

Description

[0-size Tensor No.248] Add 0-size Tensor support for reshape

paddle/phi/kernels/reshape_grad_kernel.cc 中对所有backend注册
image

PaddleAPITest 测试没有cuda error, torch 和 paddle都有shape检查
image

如果x numel为0,shape numel不为0,torch没有错误,这是因为PaddleAPITest有修改torch规则配置,返回为全0
https://github.com/PFCCLab/PaddleAPITest/blob/480b501e1fd3c480e173284c8a94d15a5c42546e/tester/paddle_to_torch/rules.py#L4641

image

@paddle-bot

paddle-bot Bot commented Jun 8, 2025

Copy link
Copy Markdown

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册。
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot Bot added the contributor External developers label Jun 8, 2025
@co63oc co63oc changed the title CI测试不review reshape [0-size Tensor No.248] Add 0-size Tensor support for reshape Jun 8, 2025
@co63oc

co63oc commented Jun 9, 2025

Copy link
Copy Markdown
Contributor Author

/re-run all-failed

@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Jun 9, 2025
@co63oc

co63oc commented Jun 9, 2025

Copy link
Copy Markdown
Contributor Author

/re-run all-failed

@co63oc

co63oc commented Jun 10, 2025

Copy link
Copy Markdown
Contributor Author

@DanielSun11 CI已完成请review

@DanielSun11

Copy link
Copy Markdown
Contributor

x numel为0,shape numel 不为0,torch会报错。

import torch
# import paddle
shape_a = [0,1,7,1]
shape_b = (52,7,1,)
a = torch.zeros(shape_a)
b = torch.reshape(a,shape_b)
Traceback (most recent call last):
  File "/home/code/test/test_reshape.py", line 6, in <module>
    b = torch.reshape(a,shape_b)
RuntimeError: shape '[52, 7, 1]' is invalid for input of size 0

请 @wanghuancoder 关注https://github.com/PFCCLab/PaddleAPITest/blob/480b501e1fd3c480e173284c8a94d15a5c42546e/tester/paddle_to_torch/rules.py#L4641 此处

@DanielSun11 DanielSun11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wanghuancoder wanghuancoder left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wanghuancoder
wanghuancoder merged commit fe41ba1 into PaddlePaddle:develop Jun 10, 2025
shanjiang7 pushed a commit to shanjiang7/Paddle that referenced this pull request Jun 12, 2025
@co63oc
co63oc deleted the d1 branch June 24, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants